package openapi

import (
	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/net/ghttp"
	"go-middle/app/openapi/api"
)

//InitRoute 开放接口路由
func InitRoute() {
	s := g.Server()
	//ci
	s.Group("/ci", func(group *ghttp.RouterGroup) {
		//验证token
		group.Middleware(func(r *ghttp.Request) {
			token := r.Header.Get("X-Gitee-Token")
			key := g.Config().GetString("ci.gitee_token")
			if token == key && key != "" {
				r.Middleware.Next()
			}
			r.Response.Status = 403
			r.Response.WritelnExit("权限不足")
		})
		group.GET("/runner", api.Runner)
	})
}
